import Cookies from 'js-cookie'

const TokenKey='loginToken'
const user ='user'


//Cookies技术

//设置TOKEN和取出
export function getToken(){
  return Cookies.get(TokenKey)
}

export function setToken(token){
  return Cookies.set(TokenKey,token)
}
export function removeToken(){
  return Cookies.remove(TokenKey)
}


//设置User和取出user
export function getUser(){
  let userInfo=Cookies.get(user);//当不存在时为空{}
  console.log(userInfo);
  if(userInfo!=undefined && Object.keys(userInfo).length>0){
   userInfo = JSON.parse(userInfo);
  }else{
    userInfo="";
  }
  return userInfo;
}
export function setUser(data){
  return Cookies.set(user,data);
}
